package RevolCraft.Handlers;

import RevolCraft.Containers.ContainerElectricFurnace;
import RevolCraft.Containers.ContainerGenerator;
import RevolCraft.GUI.GuiElectricFurnace;
import RevolCraft.GUI.GuiGenerator;
import RevolCraft.TileEntities.TileEntityElectricFurnace;
import RevolCraft.TileEntities.TileEntityGenerator;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
import cpw.mods.fml.common.network.IGuiHandler;

public class GuiHandler implements IGuiHandler {

	@Override
	public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
	{
		TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
		if(tileEntity instanceof TileEntityGenerator)
			return new ContainerGenerator(player.inventory, (TileEntityGenerator) tileEntity);
		if(tileEntity instanceof TileEntityElectricFurnace)
			return new ContainerElectricFurnace(player.inventory, (TileEntityElectricFurnace) tileEntity);
		return null;
	}

	@Override
	public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
	{
		TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
		if(tileEntity instanceof TileEntityGenerator)
			return new GuiGenerator(player.inventory, (TileEntityGenerator) tileEntity);
		if(tileEntity instanceof TileEntityElectricFurnace)
			return new GuiElectricFurnace(player.inventory, (TileEntityElectricFurnace) tileEntity);
		return null;
	}
	
}
